package chapter01.v4;

/**
 * 
 * @author buxingdeyu
 *
 */
public class Rental {
	
	private Movie _movie;
	
	private int _daysRented ;//租期

	public Rental(Movie _movie, int _daysRented) {
		super();
		this._movie = _movie;
		this._daysRented = _daysRented;
	}

	public Movie getMovie() {
		return _movie;
	}

	public void setMovie(Movie _movie) {
		this._movie = _movie;
	}

	public int getDaysRented() {
		return _daysRented;
	}

	public void setDaysRented(int _daysRented) {
		this._daysRented = _daysRented;
	}
	
	double getCharge(){
		double result = 0;
		switch (getMovie().getPriceCode()) {
			case Movie.REGULAR:
				result += 2;
				if (getDaysRented() > 2) {
					result += (getDaysRented() - 2) * 1.5;
				}
				break;
			case Movie.NEW_RELEASE:
				result += getDaysRented() * 3;
				break;
			case Movie.CHILDRENS:
				result += 1.5;
				if (getDaysRented() > 3) {
					result += (getDaysRented() - 3) * 1.5;
				}
				break;
		}
		return result;
	
	}
	
	public int getFrequentRenterPoints(){
		if(this.getMovie().getPriceCode()==Movie.NEW_RELEASE&&this.getDaysRented()>1){
			return 2;
		}else{
			return 1;
		}
	}
}
